// Language mappings remain the same as in original
const languageMap = {
  "abap": "abap",
  "ascx": "xml",
  "cls": "apex",
  "azcli": "azcli",
  "bat": "bat",
  "cmd": "bat",
  "bicep": "bicep",
  "mligo": "cameligo",
  "clj": "clojure",
  "cljs": "clojure",
  "cljc": "clojure",
  "csprog": "xml",
  "config": "xml",
  "edn": "clojure",
  "coffee": "coffeescript",
  "c": "c",
  "h": "c",
  "cpp": "cpp",
  "cc": "cpp",
  "cxx": "cpp",
  "hpp": "cpp",
  "hh": "cpp",
  "hxx": "cpp",
  "cs": "csharp",
  "csx": "csharp",
  "cake": "csharp",
  "css": "css",
  "cypher": "cypher",
  "cyp": "cypher",
  "dart": "dart",
  "dockerfile": "dockerfile",
  "dtd": "xml",
  "ecl": "ecl",
  "ex": "elixir",
  "exs": "elixir",
  "flow": "flow9",
  "ftl": "freemarker2",
  "ftlh": "freemarker2",
  "ftlx": "freemarker2",
  "fs": "fsharp",
  "fsi": "fsharp",
  "ml": "fsharp",
  "mli": "fsharp",
  "fsx": "fsharp",
  "fsscript": "fsharp",
  "go": "go",
  "graphql": "graphql",
  "gql": "graphql",
  "handlebars": "handlebars",
  "hbs": "handlebars",
  "tf": "hcl",
  "tfvars": "hcl",
  "hcl": "hcl",
  "html": "html",
  "htm": "html",
  "shtml": "html",
  "xhtml": "html",
  "mdoc": "html",
  "jsp": "html",
  "asp": "html",
  "aspx": "html",
  "jshtm": "html",
  "ini": "ini",
  "properties": "ini",
  "gitconfig": "ini",
  "java": "java",
  "jav": "java",
  "js": "javascript",
  "es6": "javascript",
  "jsx": "javascript",
  "mjs": "javascript",
  "cjs": "javascript",
  "jl": "julia",
  "kt": "kotlin",
  "kts": "kotlin",
  "less": "less",
  "lex": "lexon",
  "liquid": "liquid",
  "html.liquid": "liquid",
  "lua": "lua",
  "m3": "m3",
  "i3": "m3",
  "mg": "m3",
  "ig": "m3",
  "md": "markdown",
  "markdown": "markdown",
  "mdown": "markdown",
  "mkdn": "markdown",
  "mkd": "markdown",
  "mdwn": "markdown",
  "mdtxt": "markdown",
  "mdtext": "markdown",
  "mdx": "mdx",
  "s": "mips",
  "dax": "msdax",
  "msdax": "msdax",
  "m": "objective-c",
  "pas": "pascal",
  "p": "pascal",
  "pp": "pascal",
  "ligo": "pascaligo",
  "pl": "perl",
  "pm": "perl",
  "php": "php",
  "php4": "php",
  "php5": "php",
  "phtml": "php",
  "props": "xml",
  "ctp": "php",
  "pla": "pla",
  "pq": "powerquery",
  "pqm": "powerquery",
  "ps1": "powershell",
  "psm1": "powershell",
  "psd1": "powershell",
  "proto": "proto",
  "jade": "pug",
  "pug": "pug",
  "py": "python",
  "rpy": "python",
  "pyw": "python",
  "cpy": "python",
  "gyp": "python",
  "gypi": "python",
  "json": "python",
  "qs": "qsharp",
  "r": "r",
  "rhistory": "r",
  "rmd": "r",
  "rprofile": "r",
  "rt": "r",
  "cshtml": "razor",
  "redis": "redis",
  "rst": "restructuredtext",
  "rb": "ruby",
  "rbx": "ruby",
  "rjs": "ruby",
  "gemspec": "ruby",
  "rs": "rust",
  "rlib": "rust",
  "sb": "sb",
  "scala": "scala",
  "sc": "scala",
  "sbt": "scala",
  "scm": "scheme",
  "ss": "scheme",
  "sch": "scheme",
  "swift": "swift",
  "rkt": "scheme",
  "scss": "scss",
  "sh": "shell",
  "bash": "shell",
  "sol": "sol",
  "aes": "aes",
  "rq": "sparql",
  "sql": "sql",
  "st": "st",
  "iecst": "st",
  "iecplc": "st",
  "lc3lib": "st",
  "targets": "xml",
  "tcpou": "st",
  "tcdut": "st",
  "tcgvl": "st",
  "tcio": "st",
  "sv": "systemverilog",
  "svh": "systemverilog",
  "v": "verilog",
  "vh": "verilog",
  "tcl": "tcl",
  "twig": "twig",
  "ts": "typescript",
  "tsx": "typescript",
  "cts": "typescript",
  "mts": "typescript",
  "vb": "vb",
  "vbs": "vb",
  "wgsl": "wgsl",
  "wxi": "xml",
  "wxl": "xml",
  "wxs": "xml",
  "xaml": "xml",
  "xml": "xml",
  "xsd": "xml",
  "xsl": "xml",
  "yaml": "yaml",
  "yml": "yaml"
};


// Helper function to get Monaco language from filename and mime type
export const getMonacoLanguage = (fileName, mimeType) => {
  const ext = fileName.split('.').pop()?.toLowerCase();

  // Check if we have a direct mapping from extension
  if (ext && languageMap[ext]) {
    return languageMap[ext];
  }

  // Check mime type for specific cases
  if (mimeType) {
    if (mimeType.includes('javascript')) return 'javascript';
    if (mimeType.includes('json')) return 'json';
    if (mimeType.includes('xml')) return 'xml';
    if (mimeType.includes('html')) return 'html';
    if (mimeType.includes('markdown')) return 'markdown';
  }

  // Default to plaintext if no match found
  return 'plaintext';
};